<include file="public@header" />
</head>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:url('user/index')}">{:lang('ADMIN_USER_INDEX')}</a></li>
			<li class="active"><a href="{:url('user/add')}">{:lang('ADMIN_USER_ADD')}</a></li>
		</ul>
		<form method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:url('user/addpost')}">
			<div class="form-group">
				<label for="input-user_email" class="col-sm-2 control-label"><span class="form-required">*</span>{:lang('MOBILE')}（登录名）</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="" name="mobile">
				</div>
			</div>
			<div class="form-group">
				<label for="input-user_login" class="col-sm-2 control-label"><span class="form-required">*</span>昵称</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-user_login" name="user_login">
				</div>
			</div>
			<div class="form-group">
				<label for="input-user_pass" class="col-sm-2 control-label"><span class="form-required">*</span>{:lang('PASSWORD')}</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-user_pass" name="user_pass" placeholder="">
				</div>
			</div>						
            <div class="form-group" >
				<label for="input-user_email" class="col-sm-2 control-label" ><span class="form-required">*</span>选择店铺</label>
				<div class="col-md-6 col-sm-10">
                	<select name="store_id" class="form-control" style="width: 200px;">
                   <option value="0">请选择</option>
                   <foreach name="store_list" item="vd">
		           		<option value="{$vd.id}">{$vd.store_name}</option>
		           </foreach>
                   </select> 
                   <span style="color:red;">*添加店长和收银员时选择</span>                  
				</div>
			</div>
			<div class="form-group">
				<label for="input-user_email" class="col-sm-2 control-label"><span class="form-required">*</span>{:lang('ROLE')}</label>
				<div class="col-md-6 col-sm-10">
					<foreach name="roles" item="vo">
						<label class="checkbox-inline">
							<input value="{$vo.id}" type="radio" name="role_id[]" <if condition="cmf_get_current_admin_id() neq 1 && $vo['id'] eq 1">disabled="true"</if>>{$vo.name}
						</label>
					</foreach>
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<button type="submit" class="btn btn-primary ">{:lang('ADD')}</button>
				</div>
			</div>
		</form>
	</div>
	<script src="__STATIC__/js/admin.js"></script>
	<script type="text/javascript">	       
        $(function () {
            $('#sel').change(function () {
                var brandid = $('#sel option:selected').val();
                $.getJSON("{:url('Store/getGoods')}", { brandid: brandid }, function (json) {
                    var jsonObj = JSON.parse(json)
                    var jsonArr = []
                    for (var i = 0; i < jsonObj.length; i++) {
                        jsonArr[i] = jsonObj[i];
                    }
                    if (jsonArr.length!==0) {
                        var add = '';
                    $.each(jsonArr, function (k, v) {
                            add += '<input  type="checkbox" name="cat" value="' + v.g_id + '">' + v.g_goodsname 
                            $('#addshop').html(add)
                    })
                    } else {
                        $('#addshop').html('该分类没有商品！')
                    }
                    // 为每个动态添加的span添加样式
                    $('#addshop').find('span').css({
                        "display": "block",
                        "margin-right": "1rem",
                        "float": "left"
                    })

                });
            })
        })
    </script>
</body>
</html>